package com.dingding.common.core.util.phonesec;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import com.alibaba.fastjson.JSONObject;
import com.dingding.common.core.util.HttpTool;
import com.dingding.common.core.util.MD5Util;

/**
 * @Description:天润融通号码保护工具类
 * @author fengshuonan
 * @date 2016年10月19日 上午9:49:19
 * @version 叮叮搭车
 * @since 2.4
 */
public class PhoneSec {

	public static final String BASE_URL = "http://123.65.216.13:28083/PrivacyAppCall/api/test/call";
	public static final String ACCOUNT = "did002";
	public static final String TOKEN = "0010926114739q012pdd";
	
	

	public static void main(String[] args){
		
		//请求参数封装
		JSONObject req = new JSONObject();
		
		
		String caller = "18201309300";
		String called = "13064581540";
		long now = System.currentTimeMillis();
		Date date = new Date(now);
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
		String time = dateFormat.format(date);
		
		String sig = MD5Util.md5Encrypt(ACCOUNT + time + caller + called + TOKEN);
		
		req.put("caller", caller);
		req.put("called", called);
		req.put("sig", sig);
		
		System.out.println(req.toJSONString());
		
		HttpTool httpTool = new HttpTool();
		String postJsonGetJson = httpTool.postSelfHeaderString(BASE_URL, req.toJSONString(),time);
		
		System.out.println(postJsonGetJson);
	}

}
